package hn.cch.spring.context.boot;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;


/**
 * bean生命周期
 */
@Component
public class BeanLifeCycle {

    private static final Logger logger = LoggerFactory.getLogger(BeanLifeCycle.class);


    public BeanLifeCycle() {
        logger.info("BeanLifeCycle");
    }

    @Autowired
    public void setJavaHome(@Value("${JAVA_HOME}") String javaHome) {
        logger.info("autowire value:{}", javaHome);
    }

    @PostConstruct
    public void postConstruct() {
        logger.info("postConstruct");
    }

    @PreDestroy
    public void preDestroy() {
        logger.info("preDestroy");
    }
}
